package com.lyx.fileio2;

import java.io.*;

public class TestCopy1 {
    public static void main(String[] args) {

        Reader reader = null;
        Writer writer = null;
        try {
            //字符流
            reader = new FileReader("c:/readme.txt");
            writer = new FileWriter("c:/readme.txt");

            char[] a = new char[1024];
            int len = reader.read(a);
            while (len != -1) {
                writer.write(a, 0, len);
                len = reader.read(a);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {

            try {
                if (reader != null) {
                    reader.close();
                }

            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                if (writer!=null) {
                    writer.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }


    }
}
